﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HttpRequester;
using HttpRequester.RequestMakers.Base;
using BotvaBot.RequestChains;
using BotvaBot.RequestChainItems.Base;
using Common.Constants;
using BotvaBot.BusinessLayer.RequestChainItems.Factory;

namespace BotvaBot.RequestChainItems
{
    [ChainItem]
    public class EnterChainItem : ExtendedChainItenBase
    {
        protected override void PrepareRequestInternal()
        {
            Url = "http://g3.botva.ru";
            Method = HttpMethod.POST;
        }

        public override bool IsResponseValidInternal()
        {
            string content = Requester.PageContent;
            content = content.Replace(" ", string.Empty)
                            .Replace("'", "\"")
                            .ToUpper();
            
            string searchedStr = "<input type='submit' class='cmd_all cmd_medium_sl cmd_amedium_sl ' value='ВХОД' >";
            searchedStr = searchedStr.Replace(" ", string.Empty)
                            .Replace("'", "\"")
                            .ToUpper();
            
            return content.Contains(searchedStr);
        }
    }
}
